#!/usr/bin/env bash

if [ "`ping -c 1 corp.wan`" ]; then
    if [ ! -e "/mnt/share" ]; then
        USER=`whoami`
        sudo mount.cifs //corp.wan /mnt/corp -o credentials=/home/$USER/etc/cifs.credo,uid=$USER,forceuid,gid=$USER,forcegid,file_mode=0644,dir_mode=0755,rw,intr,soft,sec=ntlm
    else
        echo "Remote directory already mounted"
    fi
else
    echo "Corporate network not available"
    sudo umount -a -t cifs -l
fi
